'use strict';
// spu表
// spu表描述的是一个抽象性的商品，比如 iphone8
module.exports = app => {
  const { STRING, BIGINT, TINYINT } = app.Sequelize;

  const MallSpu = app.model.define('mall_spu', {
    category_id1: {
      type: BIGINT(20),
      allowNull: false,
      comment: '1级分类Id',
    },
    category_id2: {
      type: BIGINT(20),
      allowNull: false,
      comment: '2级分类Id',
    },
    category_id3: {
      type: BIGINT(20),
      allowNull: false,
      comment: '3级分类Id',
    },
    brand_id: {
      type: BIGINT(20),
      allowNull: false,
      comment: '品牌Id (商品所属的品牌)',
    },
    title: {
      type: STRING(256),
      allowNull: false,
      comment: '商品标题',
    },
    sub_title: {
      type: STRING(256),
      defaultValue: '',
      comment: '副标题 (一般是促销信息)',
    },
    saleable: {
      type: TINYINT(1),
      allowNull: false,
      defaultValue: 1,
      comment: '是否上架 (0-下架，1-上架',
    },

  });

  // MallSpecParam.associate = () => {
  //   // 存在多对一关系，所以使用belongsTo()
  //   MallSpecParam.associate = () => {
  //     app.model.MallSpecParam.belongsTo(app.model.MallCategory, { foreignKey: 'category_id' });
  //   };
  //   MallSpecParam.associate = () => {
  //     app.model.MallSpecParam.belongsTo(app.model.MallSpecGroup, { foreignKey: 'group_id' });
  //   };
  // };
  return MallSpu;
};
